﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccessLayer.Entity;
using System.Data;
namespace DataAccessLayer.Adapter
{
    public class MonThiAdapter
    {
        clsKetNoiCSDL kn = new clsKetNoiCSDL();
        public DataTable LoadMonThi()
        {
            return kn.LoadDL("tbMonThi_SelectAll");
        }
        public void ThemMonThi(clsMonThi clsMon)
        {
            int Npa = 3;
            string sql = "tbMonThi_Insert";
            string[] name = new string[Npa];
            object []value=new object[Npa];
            name[0] = "@MaMon"; value[0] = clsMon.MaMonThi;
            name[1] = "@TenMon"; value[1] = clsMon.TenMonThi;
            name[2] = "@GhiChu"; value[2] = clsMon.GhiChu;
            kn.UpdateDL(sql,name,value,Npa);
        }

        public void SuaMonThi(clsMonThi clsMon)
        {
            int Npa = 3;
            string sql = "tbMonThi_Update";
            string[] name = new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@MaMon"; value[0] = clsMon.MaMonThi;
            name[1] = "@TenMon"; value[1] = clsMon.TenMonThi;
            name[2] = "@GhiChu"; value[2] = clsMon.GhiChu;
            kn.UpdateDL(sql, name, value, Npa);
        }

        public void XoaMonThi(clsMonThi clsMon)
        {
            int Npa = 1;
            string sql = "tbMonThi_Delete";
            string[] name = new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@MaMon"; value[0] = clsMon.MaMonThi;
            //name[1] = "@TenMon"; value[1] = clsMon.TenMonThi;
            //name[2] = "@GhiChu"; value[2] = clsMon.GhiChu();
            kn.UpdateDL(sql, name, value, Npa);
        }

        public object KiemTraMaMon(clsMonThi clsMon)
        {
            int Npa = 1;
            string sql = "tbMonThi_KiemTraMa";
            string[] name=new string[Npa];
            object []value=new object[Npa];
            name[0]="@MaMon";value[0]=clsMon.MaMonThi;
            return kn.KTTrungMa(sql,name,value,Npa);
        }
    }
}
